package com.tengju.user.domain.model.survey;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum SurveyQuestionTypeEnum {
    RADIO(1,"单选"),
    CHECKBOX(2,"多选"),
    DATE(3,"日期"),
    SWITCH(4,"开关"),
    INPUT(5,"文本输入"),
    TEXT(6,"段落"),
    MANY_TEXT(7,"多文本框"),
    PICTURE(8,"图片"),
    TRUE_OR_FALSE_DEFALT_FALSE(9,"是否选择(默认否)");

    private Integer code;
    private String desc;

    SurveyQuestionTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SurveyQuestionTypeEnum parseByCode(Integer code) {
        return Arrays.stream(SurveyQuestionTypeEnum.values())
                .filter(k -> k.getCode().equals(code))
                .findFirst().orElse(null);
    }

}
